package com.hele.sts.webdoc;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.hele.sts.pub.SqlQuery;

public class createTreeBean
{
  public static String getTreeStr(String nbxh, String opType)
  {
    ResultSet rs = null;
    String treeStr = "d = new dTree('d');   ";
    int rowNum = 0;
    treeStr = treeStr + "d.add(0,-1,'正卷');   ";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select jnmlbh,trim(jnmlmc) from da_qyzfjzmlb   where nbxh='" + 
      nbxh + "' order by jnmlbh ";
    try
    {
      rs = sqlquery.getResultSet(sqlstr);
    }
    catch (SQLException e1)
    {
      e1.printStackTrace();
    }
    if (rs != null)
    {
      try
      {
        while (rs.next()) {
          treeStr = 
            treeStr + "d.add(" + rs.getString(1) + ",0,'" + rs.getString(2) + "');   ";
        }
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }
      try
      {
        rowNum = rs.getRow();
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }
      finally
      {
        try
        {
          rs.close();
        }
        catch (SQLException e)
        {
          e.printStackTrace();
        }
      }
    }
    sqlstr = "select djjg from hz_qyhznr  where nbxh='" + nbxh + "' ";
    String djjg = "";
    try
    {
      rs = sqlquery.getResultSet(sqlstr);
    }
    catch (SQLException e1)
    {
      e1.printStackTrace();
    }
    if (rs != null)
    {
      try
      {
        if (rs.next()) {
          djjg = rs.getString(1);
        }
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }
      try
      {
        rs.close();
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }
    }
    sqlstr = 
      "select inmlbh+100,jnmlbh,inmlbh,trim(clmlmc),trim(wjljmc) from da_qyjnmlb where nbxh='" + nbxh + "'  order by jnmlbh,inmlbh ";
    try
    {
      rs = sqlquery.getResultSet(sqlstr);
    }
    catch (SQLException e1)
    {
      e1.printStackTrace();
    }
    if (rs != null)
    {
      try
      {
        while (rs.next()) {
          treeStr = 
          



            treeStr + "d.add(" + rs.getString(1) + "," + rs.getString(2) + ",'" + rs.getString(4) + "','tifContent.jsp?nbxh=" + nbxh + "&djjg=" + djjg + "&jnmlbh=" + rs.getString(2) + "&inmlbh=" + rs.getString(3) + "','" + rs.getString(4) + "', 'mainContent');   ";
        }
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }
      try
      {
        rs.close();
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }
    }
    try
    {
      sqlquery.close();
    }
    catch (SQLException e1)
    {
      e1.printStackTrace();
    }
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception e)
    {
      System.out.println(e.getMessage());
    }
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException3) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException4) {}
    return treeStr;
  }
}
